//
//  AYMTumorViewController.m
//  QuickCure
//
//  Created by kangkang on 16/5/5.
//  Copyright © 2016年 ayumi. All rights reserved.
//


#import "AYMTumorViewController.h"

#import "AYMDetailController.h"

#import "AYMSymptomController.h"

#import "AYMMethodController.h"

#import "AYMDoctorController.h"

@interface AYMTumorViewController ()<methodDelegate,symptomDelegate,detailDelegate>


# pragma mark -
# pragma mark - 属性
//疾病类型
@property (weak, nonatomic) IBOutlet UILabel *sortLabel;

//病情详情
@property(nonatomic,weak)   IBOutlet UILabel *detailLabel;

@property(nonatomic,weak)   IBOutlet UIButton *detailButton;

//symptom病情症状
@property (weak, nonatomic) IBOutlet UILabel *symptomLabel;

@property(nonatomic,weak)   IBOutlet UIButton *symptomButton;

//是否确诊
@property(nonatomic,weak)   IBOutlet UILabel *sureLabel;

@property (weak, nonatomic) IBOutlet UIButton *sureBtn;

@property(nonatomic,weak)   IBOutlet UIButton *unsureButton;

//是否接受过治疗
@property(nonatomic,weak)   IBOutlet UILabel *histoyrLabel;

@property(nonatomic,weak)   IBOutlet UIButton *acceptButton;

@property(nonatomic,weak)   IBOutlet UIButton *unacceptButton;

//治疗方式
@property(nonatomic,weak)   IBOutlet UILabel *methodLabel;

@property(nonatomic,weak)   IBOutlet UIButton *methodButton;
@property (weak, nonatomic) IBOutlet UIView *methodView;

//匹配label
@property(nonatomic,strong) UILabel *matchLabel;

//匹配到医生数量
@property(nonatomic,weak)  IBOutlet UILabel *numberLabel;

//医生头像
@property(nonatomic,strong)UIImageView *iconImageView;

//申请label
@property(nonatomic,weak)  IBOutlet UIButton *applyButton;

@end

@implementation AYMTumorViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];

 }

-(void)setupUI{
    
    self.applyButton.layer.cornerRadius = 5;
    
    self.applyButton.layer.masksToBounds = YES;
    
    self.view.backgroundColor = [UIColor colorWithRed:242/255.0 green:242/255.0 blue:242/255.0 alpha:1];
    
    //导航栏右侧清空按钮
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:@"清空" style:UIBarButtonItemStylePlain target:self action:@selector(didClearn:)];
    
    self.navigationItem.rightBarButtonItem = item;
    
    self.navigationItem.title = [NSString stringWithFormat:@"%@疾病详情选择",self.buttonString];
    
    self.sortLabel.text = [NSString stringWithFormat:@"疾病类型：%@疾病",self.buttonString];
    
    //设置选项按钮的状态
    [self.sureBtn setImage:[UIImage imageNamed:@"illness_rb_img_sel.png"] forState:UIControlStateSelected];
    
    self.sureBtn.selected = YES;
    
    [self.unsureButton setImage:[UIImage imageNamed:@"illness_rb_img_sel.png"] forState:UIControlStateSelected];
    
    [self.acceptButton setImage:[UIImage imageNamed:@"illness_rb_img_sel.png"] forState:UIControlStateSelected];
    
    self.acceptButton.selected = YES;
    
    [self.unacceptButton setImage:[UIImage imageNamed:@"illness_rb_img_sel.png"] forState:UIControlStateSelected];
    
}

# pragma mark -
# pragma mark - 导航栏右侧清空按钮

-(void)didClearn:(UIBarButtonItem *)item{
    
    UIAlertController *alertVc = [UIAlertController alertControllerWithTitle:@"提示" message:@"确定要清空所有选项吗" preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        self.sureBtn.selected = YES;
        
        self.unsureButton.selected = NO;
        
        self.acceptButton.selected = YES;
        
        self.unacceptButton.selected = NO;
        
        self.detailLabel.text = @"请选择疾病细分";
        
        self.detailLabel.textColor = [UIColor lightGrayColor];
        
        self.symptomLabel.text = @"请选择并发症（可多选）";
        
        self.symptomLabel.textColor = [UIColor lightGrayColor];
        
        self.methodLabel.text = @"请选择治疗方式";
        
        self.methodLabel.textColor = [UIColor lightGrayColor];
        
        [self.applyButton setBackgroundImage:[UIImage imageNamed:@"illness_img_line.png"] forState:UIControlStateNormal];
    }];
    
    
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    
    [alertVc addAction:sureAction];
    
    [alertVc addAction:cancelAction];
    
    
    [self presentViewController:alertVc animated:YES completion:nil];
    
    
}


# pragma mark -
# pragma mark - surebutton，unsurebutton,accept，unaccept按钮点击切换状态
- (IBAction)didSureBtn:(UIButton *)sender {
    
    sender.selected = YES;
    
    self.unsureButton.selected = NO;
    
}

- (IBAction)didUnsureBtn:(UIButton *)sender {
    
    sender.selected = YES;
    
    self.sureBtn.selected = NO;
    
}

- (IBAction)didAcceptBtn:(UIButton *)sender {
    
    sender.selected = YES;
    
    self.unacceptButton.selected = NO;
    
    //设置methodLabel是否隐藏
    self.methodView.hidden = !self.acceptButton.selected;
    
}

- (IBAction)didUnacceptBtn:(UIButton *)sender {
    
    sender.selected = YES;
    
    self.acceptButton.selected = NO;
    
    //设置methodLabel是否隐藏
    self.methodView.hidden = !self.acceptButton.selected;
}

# pragma mark -
# pragma mark - 点击detail，symptom，method按钮跳转View
- (IBAction)didDetailBtn:(id)sender {
    
    AYMDetailController *detailVc = [[AYMDetailController alloc] init];
    
    detailVc.delegate = self;
    
    [self.navigationController pushViewController:detailVc animated:YES];
    
}

- (IBAction)didSymptomBtn:(id)sender {
    
    AYMSymptomController *symVc = [[AYMSymptomController alloc] init];
    
    symVc.delegate = self;
    
    [self.navigationController pushViewController:symVc animated:YES];
    
    
}

- (IBAction)didMethodBtn:(id)sender {
    
    AYMMethodController *methodVc = [[AYMMethodController alloc] init];
    
    methodVc.delegate = self;
    
    [self.navigationController pushViewController:methodVc animated:YES];
    
}


# pragma mark -
# pragma mark - 点击申请医生按钮
- (IBAction)didApplyBtn:(id)sender {
    
    if (self.detailLabel.textColor == [UIColor blackColor]) {
        
        AYMDoctorController *doctorVc = [[AYMDoctorController alloc] init];
        
        [self.navigationController pushViewController:doctorVc animated:YES];
        
    }else{
        
        [SVPAlertManager alertErrorStatus:@"请填写疾病细分"];
        
    }
    
}

# pragma mark -
# pragma mark - 代理方法的实现

-(void)methodDelegateWith:(NSString *)method{
    
    self.methodLabel.text = method;
    
    self.methodLabel.textColor = [UIColor blackColor];
    
    }

-(void)symptomdelegateWith:(NSString *)title{
    
    self.symptomLabel.text = title;
    
    self.symptomLabel.textColor = [UIColor blackColor];
    
    }

-(void)detaildelegateWith:(NSString *)title{
    
    self.detailLabel.text = title;
    
    self.detailLabel.textColor = [UIColor blackColor];
    
    self.applyButton.backgroundColor = [UIColor colorWithRed:81/255.0 green:185/255.0 blue:185/255.0 alpha:1];
    
    [self.applyButton setBackgroundImage:nil forState:UIControlStateNormal];
    
}

@end
